/*
 * Event.java
 * Team qq 2011
 */
package com.google.code.timetrail.backend;

import java.io.Serializable;

/**
 * This event will act as a temporary wrapper for an event's text
 * it might eventually do actions, but that's not gonna be implemented now
 * BOUNUS! IT FORMATS THE TEXT #wow #whoa
 * @author Steven
 * @version 1.0
 */
public class Event implements Serializable {

	protected String messageText;
	/**
	 * 
	 */
	private static final long serialVersionUID = 50L;
	
	private final String dummyEvent = "NO_CURRENT_EVENT";
	/**
	 * Formats the text in Message String to be a beautiful 80 characters per line
	 * @param messageText
	 */
	
	private Control gameControl;
	public Event(String messageText, Control gameControl){
	    this.gameControl = gameControl;
		this.messageText = "";
		formatMessage(messageText);
	}
	
	public Event(Control gameControl){
	    this.gameControl = gameControl;
		messageText = dummyEvent;
	}
	public Event(){
	    messageText = dummyEvent;
	}
	
	public void formatMessage(String messageText){
	    this.messageText = "";
	    for(int i = 0; i < messageText.length(); i++){
            if(i != 0 && i % 78 == 0 && messageText.charAt(i) != ' '){
                this.messageText += "-";
            }
            else if(i != 0 && i % 79 == 0){
                this.messageText += "\n";
            }
            else{
                this.messageText += messageText.charAt(i);
            }
        }
	}
	public  String getDummyText(){
		return dummyEvent;
	}
	public Control getControl(){
	    return gameControl;
	}
	public void Action(){
	    
	}
	
	/**
	 * returns the message text for future use
	 * @return the formatted message text
	 */
	public String getMessageText(){
		return messageText;
	}
	
}
